﻿<%@ Page Language="C#" Title="mvc 测试页面" MasterPageFile="~/W_View/PageMaster.Master" CodeBehind="TestPage1.aspx.cs" Inherits="STHPMS1.Web.W_View.TestPage.TestPage1" %>

<%--<%@ Import Namespace="STHPMS1.ICore.I_Entity" %>--%>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/datagrid.js")%>

    <script type="text/javascript">      

        function testEdit(flag)
        {
            var row = $('#dg').datagrid('getSelected');
            var title="";
            if (flag == 0)
            {
                if (!row) {
                    $.messager.alert('消息提示', '编辑数据时，请选择一项!', 'warning');
                    return;
                }
                $('#fm').form('load', row);
                title="新增测试数据";
            }
            else
            {
                $('#fm').form('clear');
                title="编辑测试数据";
            }

            $('#dlg').dialog('open');
        }

        function testDel() {
            var row = $('#dg').datagrid('getSelected');
            if (!row) {
                $.messager.alert('消息提示', '删除数据时，请选择一项!', 'warning');
                return;
            }

            deleteData($('#dg'), $('#dlg'), "/api/test");
        }



        function search(n,o) {
            var region = $('#cmbRegion').combobox("getValue");
            var direction = $('#cmbDirection').combobox("getValue");
            var checkDate = $('#checkDate').datebox('getValue');  //注意.datebox('getValue')

            var url = '/api/test';
            var urlParam = "";
            if (region != "" && region!="0") urlParam += "region=" + encodeURI(region) + "&";
            if (direction != "" && direction!="0") urlParam += "direction=" + encodeURI(direction) + "&";
            if (checkDate != "") urlParam += "checkDate=" + encodeURI(checkDate) + "&";
            if (urlParam != "") {
                urlParam = "?" + urlParam.substring(0, urlParam.length - 1);
                url = url + urlParam;
            }

            $('#dg').datagrid({ url:  url,pageNumber:1});
        }
       

        $(function () {
            var number= '<%= Page.RouteData.Values["page"] %>';
            var size = '<%= Page.RouteData.Values["size"] %>';

            dataGridBind($('#dg'), '/api/test', '测试数据列表显示', $('#tb'), number, size);

            $('.validatebox-text').bind('blur', function () {
                $(this).validatebox('enableValidation').validatebox('validate');
            });
        })
    </script>    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table id="dg" class="easyui-datagrid content-place"  ajaxCached="false"  >
        <thead>
            <tr>
                <th data-options="field:'Id',width:80">商品 ID</th>
                <th data-options="field:'Name',width:240">商品名称</th>
                <th data-options="field:'Unit',width:80,editor:'text'">单位</th>
                <th data-options="field:'UnitPrice',width:80,align:'right',editor:{type:'numberbox',options:{precision:1}}">单价</th>
                <th data-options="field:'Quantity',width:60,align:'right',editor:'numberbox'" formatter="formatPile">数量</th>
            </tr>
        </thead>
    </table>
   
    <!--测试数据命令-->
    <div id="tb">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="testEdit(-1)">添加</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="testEdit(0)">编辑</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="testDel()">删除</a>
	    <input id="cmbRegion" class="easyui-combotree" style="width:300px" data-options="prompt:'行政区划',url:'/api/data/regioncode',method:'get',onChange:search"/>
	    <input id="checkDate" class="easyui-datebox"  data-options="prompt:'观测日期',onChange:search"/>
	    <select id="cmbDirection" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'调查方向',url:'/api/data/direction',method:'get',valueField:'id',textField:'text',onChange:search">
         </select>
    </div>

    <!--测试详细页面-->
    <div id="dlg" class="easyui-dialog" title="保存数据" style="width:320px;height:250px;padding:10px" closed="true"  data-options="
				iconCls: 'icon-save',
				buttons: '#dlg-buttons'
			">
        <form id="fm" method="post" action="/api/test">
            <table>
			    <tr>
				    <td>Id:</td>
				    <td><input name="Id" class="easyui-validatebox textbox" /></td>
			    </tr>
			    <tr>
				    <td>Name:</td>
				    <td><input name="Name" class="easyui-validatebox textbox" data-options="required:true,validType:'email',novalidate:true" /></td>
			    </tr>
			    <tr>
				    <td>Unit:</td>
				    <td><input name="Unit" class="easyui-validatebox textbox" data-options="required:true,validType:'url',novalidate:true"/></td>
			    </tr>
			    <tr>
				    <td>UnitPrice:</td>
				    <td><input name="UnitPrice" class="easyui-validatebox textbox" data-options="required:true,validType:'Number'" /></td>
			    </tr>
			    <tr>
				    <td>Quantity:</td>
				    <td><input name="Quantity" class="easyui-validatebox textbox" data-options="required:true,validType:'Number'" /></td>
			    </tr>
		    </table>
        </form>
    </div>

    <!--编辑数据命令-->
    <div id="dlg-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:sumbitData($('#dg'),$('#dlg'))">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dlg').dialog('close')">取消</a>
	</div>
</asp:Content>
